from functools import wraps
from flask import g, redirect


# 登陆检查
def check_login(func):
    @wraps(func)
    def doCheck(*args, **kwargs):
        if hasattr(g, 'user'):
            return func(*args, **kwargs)
        else:
            return redirect('/auth/')
    return doCheck
